package cn.tedu.crm.dashboard.service.impl;

import cn.tedu.crm.dashboard.pojo.vo.*;
import cn.tedu.crm.dashboard.service.DashboardService;
import cn.tedu.crm.dashboard.mapper.DashboardMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


import java.util.List;

/**
* @author tedu
* @description 针对表【customer(客户表)】的数据库操作Service实现
* @createDate 2025-03-25 20:33:26
*/
@Service
public class DashboardServiceImpl implements DashboardService {

    @Autowired
    private DashboardMapper dashboardMapper;

    @Override
    public List<TaskVO> selectTaskList() {
        return dashboardMapper.selectTaskList();
    }

    @Override
    public List<RankVO> selectRankList() {
        return dashboardMapper.selectRankList();
    }

    @Override
    public List<OrderStatsVO> selectorderStats() {
        List<OrderStatsVO> list = dashboardMapper.selectorderStats();
        for(OrderStatsVO vo : list){
            vo.setOrderIndex(dashboardMapper.selectCost());
        }
        return list;
    }

    @Override
    public List<VisitStatsVO> selectorderVisitStats() {
        List<VisitStatsVO>list = dashboardMapper.selectorderVisitStats();
        for(VisitStatsVO vo : list){
            vo.setUserIndex(dashboardMapper.selectUser());
        }
        return list;
    }

    @Override
    public ProductionStatsVO selectorderProductionStats() {
        ProductionStatsVO list = dashboardMapper.selectorderProductionStats();
        if (list == null) {
            list = new ProductionStatsVO();
            list.setWeek(0.0);
            list.setActual(0.0);
            list.setToday(0.0);
            list.setMonth(0.0);
        }
        list.setCostIndex(dashboardMapper.selectCosts());
        return list;
    }
}


